{block name=body} {* Define the function *} {function name=render_product_list cnt=0 level=0}
<div class="featured-products">
    <div class="category-wrapper">
        {foreach $items.listings as $cat}
        <div>
            {foreach $cat.products as $item} {if $item.product_flag1 eq 1} {include file='product.tpl' cnt=$cnt++} {/if} {/foreach}
        </div>
        {/foreach}
    </div>
    <div class="text-center">
        <button class="btn btn-info" onclick="$('.featured-products').toggle(); $('html,body').animate({ scrollTop : $('#products').offset().top });">加载更多商品</button>
    </div>
</div>
<div class="featured-products" style="display:none;">
    {foreach $items.listings as $cat}
    <div class="category-wrapper featured-products" style="display:none;">
        <h3>{$cat.listing_name}</h3>
        <div>
            {foreach $cat.products as $item} {include file='product.tpl' cnt=$cnt++} {/foreach}
        </div>
    </div>
    {/foreach}
</div>
{/function}
<div class="row" id="member-details">
    <div class="col-sm-12">
        <h1>{$user.user_gname} {$user.user_surname}</h1> {$address.B.address_line1}
        <br /> {$address.B.address_suburb}, {$address.B.address_state} {$address.B.address_postcode}
        <br /> {$user.user_email}
        <br /> {$address.B.address_telephone}
        <br />
    </div>
</div>
<div class="row top-margin">
    <div class="col-sm-9">
        <div class="panel-group" id="accordion">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h4 class="panel-title">
						<a data-toggle="collapse" data-parent="#accordion" href="#products">
							商品
							<span class="glyphicon glyphicon-ok pull-right" id="checked-step4" {if $step lte 4}style="display:none;"{/if}></span>
							<span class="glyphicon glyphicon-unchecked pull-right" id="unchecked-step4" {if $step gt 4}style="display:none;"{/if}></span>
						</a>
					</h4>
                </div>
                <div id="products" class="panel-collapse collapse {if $step eq 4}in{/if} step4">
                    <div class="panel-body">
                        {call name=render_product_list items=$products}
                        <div class="text-center">
                            &nbsp;
                            <hr>
                            <button id="step4-btn" type="button" class="btn btn-default side-padding" onclick="GoToStep(5)">下一步</button>
                        </div>
                    </div>
                </div>
            </div>
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h4 class="panel-title">
						<a data-toggle="collapse" data-parent="#accordion" href="#extras">
							附加费用 / 折扣
							<span class="glyphicon glyphicon-ok pull-right" id="checked-step5" {if $step lte 5}style="display:none;"{/if}></span>
							<span class="glyphicon glyphicon-unchecked pull-right" id="unchecked-step5" {if $step gt 5}style="display:none;"{/if}></span>
						</a>
					</h4>
                </div>
                <div id="extras" class="panel-collapse collapse {if $step eq 5}in{/if} step5">
                    <div class="panel-body">
                        <form class="form-horizontal" id="additional-form" role="form" accept-charset="UTF-8" action="" method="post">
                            <input type="hidden" value="setAdditional" name="action" />
                            <input type="hidden" name="formToken" id="formToken" value="{$token}" />
                            <div class="form-group">
                                <label class="col-sm-3 control-label">描述</label>
                                <div class="col-sm-9">
                                    <input type="text" value="{$additional.description}" class="form-control" id="additional-input" name="additional[description]">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">总计 ({$CURRENCY_SYMBOL})</label>
                                <div class="col-sm-9">
                                    <input type="text" value="{$additional.amount}" class="form-control double" name="additional[amount]" onchange="if(this.value){ $('#additional-input').attr('required','required') } else { $('#additional-input').removeAttr('required') }">
                                    <span class="help-block">(-) 代表折扣</span>
                                </div>
                            </div>
                            <div class="text-center">
                                <button id="step5-btn" type="submit" class="btn btn-default side-padding">下一步</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h4 class="panel-title">
						<a data-toggle="collapse" data-parent="#accordion" href="#payment">
							<span id="step6-tab-name">支付</span>
							<span class="glyphicon glyphicon-ok pull-right" id="checked-step6" {if $step lte 6}style="display:none;"{/if}></span>
							<span class="glyphicon glyphicon-unchecked pull-right" id="unchecked-step6" {if $step gt 6}style="display:none;"{/if}></span>
						</a>
					</h4>
                </div>
                <div id="payment" class="panel-collapse collapse {if $step eq 6}in{/if} step6">
                    <div class="panel-body">
                        <div id="payment-wrapper" {if $step lte 5}style="display:none;" {/if}>
                            <form class="form-horizontal" id="payment-form" role="form" accept-charset="UTF-8" action="" method="post">
                                <input type="hidden" value="PlaceOrder" name="action" />
                                <input type="hidden" name="formToken" id="formToken" value="{$token}" />
                                <div class="not-trial" id="payment-methods-wrapper">
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">总金额: </label>
                                        <div class="col-sm-9">
                                            <div class="form-text-element">{$CURRENCY_SYMBOL}<span class="payment-amount">{$totals.total}</span> <span class="ccsurchage"> + 2% credit card surchage = </span> <span class="ccsurchage"><b id="cctotal">$0</b></span></div>
                                            <input style="display:inline-block" type="hidden" id="payment-amount" value="{$totals.total}" data-amount="{$totals.total}" class="cc-req form-control double payment-amount" name="cc[amount]">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">支付方式: </label>
                                        <div class="col-sm-3 form-text-element">
                                            <input type="radio" value="cc" checked name="payment-method"> 信用卡
                                        </div>
                                        <div class="col-sm-3 form-text-element">
                                            <input type="radio" value="bt" name="payment-method"> 银行转账
                                        </div>
                                    </div>
                                    <div id="cc-wrapper">
                                        <div class="form-group">
                                            <label class="col-sm-3 control-label" for="ccno">信用卡号*</label>
                                            <div class="col-sm-6">
                                                <input type="text" id="ccno" class="cc-req form-control" name="cc[number]" autocomplete="off" required/>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-3 control-label" for="ccname">持卡人姓名*</label>
                                            <div class="col-sm-6">
                                                <input type="text" id="ccname" value="{$user.user_gname} {$user.user_surname}" class="cc-req form-control" name="cc[name]" autocomplete="off" required />
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-3 control-label" for="ccmonth">到期日期*</label>
                                            <div class="col-sm-3">
                                                <select id="ccmonth" name="cc[month]" class="cc-select-req form-control required">
                                                    <option value="">Month</option>
                                                    <option value="01">1 - Jan</option>
                                                    <option value="02">2 - Feb</option>
                                                    <option value="03">3 - Mar</option>
                                                    <option value="04">4 - Apr</option>
                                                    <option value="05">5 - May</option>
                                                    <option value="06">6 - Jun</option>
                                                    <option value="07">7 - Jul</option>
                                                    <option value="08">8 - Aug</option>
                                                    <option value="09">9 - Sep</option>
                                                    <option value="10">10 - Oct</option>
                                                    <option value="11">11 - Nov</option>
                                                    <option value="12">12 - Dec</option>
                                                </select>
                                            </div>
                                            <div class="col-sm-3">
                                                <select id="ccyear" name="cc[year]" class="cc-select-req form-control required">
                                                    {assign var=thisyear value=$smarty.now|date_format:"%Y"} {assign var=numyears value=$thisyear+20}
                                                    <option value="">Year</option>
                                                    {for $year=$thisyear to $numyears}
                                                    <option value="{$year}">{$year}</option>
                                                    {/for}
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-3 control-label" for="cccsv">CSV*</label>
                                            <div class="col-sm-3">
                                                <input type="text" id="cccsv" name="cc[csv]" class="cc-req form-control" autocomplete="off" required />
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-12 text-center" id="no-payment-required" style="display:none;">
                                    <b>不需要支付。</b>
                                    <br> &nbsp;
                                </div>
                                <div class=" col-sm-offset-3 error-alert" style="display:none;">
                                    <div class="alert alert-danger fade in ">
                                        <button class="close" aria-hidden="true" type="button" onclick="$(this).closest('.error-alert').fadeOut('slow');">&times;</button>
                                        <strong></strong>
                                    </div>
                                </div>
                                <div class="text-center">
                                    <button id="step6-btn" type="submit" onclick="if($(this).closest('form').valid()){ $('#step6-btn').hide();$('#processing-div').show(); }" class="btn btn-default side-padding">订购</button>
                                    <div style="display:none;" id="processing-div" class="btn btn-default side-padding">处理中...</div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--col-sm-9-->
    <div class="col-sm-3">
        <div id="fixedinfo" class="panel panel-default">
            <div class="panel-heading">
                <h4 class="panel-title">Summary</h4>
            </div>
            <div class="panel-body" id="cart-summary">
                {include file='shopping-cart.tpl'}
            </div>
            <div class="panel-footer">
                <form class="form-horizontal" id="reset-cart-form" method="post">
                    <input type="hidden" value="ResetCart" name="action" id="action" />
                    <input type="hidden" name="formToken" value="{$token}" />
                    <button type="button" onclick="if (confirm('Do you want to reset the shopping cart?')) { $('#reset-cart-form').submit(); }" class="btn btn-default">重置</button>
                </form>
            </div>
        </div>
    </div>
</div>
{/block} {block name=tail}
<script type="text/javascript">
$(document).ready(function() {
	{if $step eq 6}
	CheckPaymentMethod(); 
	{/if}
	CheckPaymentRequired();
	$('.product-forms').each(function() {
	    $(this).validate({
	        onkeyup: false,
	    });
	});

	$('#additional-form').validate({
	    onkeyup: false,
	});

	$('#payment-form').validate({
	    onkeyup: false
	});

	$('#reset-cart-form').validate();


	$('.double').rules("add", {
	    number: true
	});

	$('#ccno').rules("add", {
	    creditcard: true,
	});

	$('#cccsv').rules("add", {
	    digits: true,
	    minlength: 3
	});
});
</script>
{/block}
